<!DOCTYPE html>
<html lang="en" xmlns="http://www.w3.org/1999/html">
<head>
    <meta charset="UTF-8">
    <title>阳光物流管理系统</title>
    <link rel="stylesheet" href="css/font.css">
    <link rel="stylesheet" href="css/login.css">
    <link rel="stylesheet" href="css/xadmin.css">
    <link rel="stylesheet" href="layui/css/layui.css">
    <script src="layui/layui.js"></script>
</head>
<body class="login-bg">
<div class="login layui-anim layui-anim-up">
    <div class="message">阳光物流管理系统</div>
    <div id="darkbannerwrap"></div>
    <form id="address" method="post" class="layui-form">
        <input placeholder="用户名" type="text" name="user_name" lay-verify="required" class="layui-input">
        <hr class="hr15">
        <input type="password" name="password" lay-verify="required" placeholder="密码" class="layui-input">
        <hr class="hr15">
        <input type="button" id="btnLogin" value="登陆" lay-submit style="width:100%">
        <hr class="hr15">
        <label>没有账号？<a href="registe.html">点此注册</a></label>
        <hr class="hr20">
    </form>
</div>
</body>
</html>
<script src="js/jquery-3.6.0.js"></script>
<script>
    layui.use(['layer','form'],function (){
        var form = layui.form;
        $(function () {
            $("#btnLogin").click(function () {
                var data = $("#address").serialize();
                $.post("http://localhost:8080/login", data, function (rs) {
                    if (rs.code == 0) {
                        layer.msg("登陆成功", {icon: 6});
                        sessionStorage.setItem("cid", rs.data[0].cid);
                        sessionStorage.setItem("user_name",rs.data[0].user_name);
                        setTimeout(function () {
                                location.href = 'index.html';
                            },
                            1000
                        );
                    } else {
                        sessionStorage.removeItem("cid");
                        layer.msg("登陆失败", {icon: 5});
                        setTimeout(function () {
                                location.reload();//刷新页面
                            },
                            1000
                        );
                    }
                });
            });
        })
    });
</script>